const {Article} = require('../../model/article');
const {Comment} = require('../../model/comment')

const paht = require('path');

module.exports = async (req,res) => {
    const id = req.query.id
    // res.send(id);
    // console.log(id);

    const users1 = await Article.findOne({_id: id}).populate('author');
    const comments1 = await Comment.find({aid: id}).populate('uid');

    const users2 = JSON.stringify(users1);
    const users = JSON.parse(users2);

    const comments2 = JSON.stringify(comments1);
    const comments = JSON.parse(comments2);
    

    // res.send(comment)
    // console.log(comments);
    // return
    res.render('home/article',{
        users: users,
        comments: comments
    })
}